<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Android-WebView</title>
</head>
<body>
    <a href="http://www.baidu.com/">http://www.baidu.com/</a>
    <a href="#" onclick="showAlert()">showAlert()</a>
    <a href="#" onclick="showConfirm()">showConfirm()</a>
    <a href="#" onclick="showPrompt()">showPrompt()</a>
    <a href="#" onclick="AndroidCallJs1()">Android通过loadUrl调用js</a>
    <a href="#" onclick="AndroidCallJs2()">Android通过evaluateJavascript调用js</a>    <a href="#" onclick="onAndroidFunction()">onAndroidFunction</a>
    <a href="#" onclick="onAndroidFunction()">js调用Android</a>
    <h1>Hello World</h1>
    <script>
        function showAlert (msg) {
            alert('这是alert对话框');
            <!--alert(msg);-->
        }

        function showConfirm () {
            var result = confirm('这是confirm对话框');
            if (result) {
                alert('点击了确定按钮');
            } else {
                alert('点击了取消按钮');
            }
        }

        function showPrompt () {
            var res = prompt('这是prompt对话框', '这是默认的提示内容');
            alert(res);
        }

        function sum (x , y) {
            var result = x + y;
            return x + '+' + y  + ' = ' + result;
        }

        function AndroidCallJs1 () {
            alert('使用loadUrl形式，Android调用js。无法获取返回值');
        }

        function AndroidCallJs2 (x , y) {
            var result = x + y;
            return x + '+' + y  + ' = ' + result;
        }

        function onAndroidFunction () {
            var result = android.showToast('js调用Android原生代码');
            alert(result);
        }
    </script>
</body>
</html>